package com.yungui.consul.provider.controller;

import com.yungui.response.BaseResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/test")
public class TestController {
    Logger logger = LoggerFactory.getLogger(getClass());

    @Value("${server.port}")
    private String port ;

    @RequestMapping(value = "/demo1")
    @ResponseBody
    public BaseResponse demo1(String name){
        logger.info("请求demo1:{}",name);
        if ("exception".equals(name)){
            throw new RuntimeException("报错了");
        }
        return new BaseResponse(port+":"+name);
    }
}
